package edu.guet.server.controller;

import edu.guet.server.model.vo.HomeCourseIntroduceVO;
import edu.guet.server.service.HomeCourseIntroduceService;
import edu.guet.server.utils.ResultAPI;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping
@Slf4j
public class HomeCourseIntroduceController {

    @Autowired
    private HomeCourseIntroduceService introduceService;

    @PostMapping("/semester/showintro")
    public ResultAPI showIntroduce(@RequestBody Map<String, String> request){
        Long semester_id = Long.valueOf(request.get("semester_id"));
        HomeCourseIntroduceVO introduceVO = introduceService.getIntroduce(semester_id);
        if (introduceVO == null){
            return ResultAPI.error("不存在对应信息");
        }
        return ResultAPI.success(introduceVO);
    }
}
